package com.liu.my_blog_system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liu.my_blog_system.mapper.TbLooperMapper;
import com.liu.my_blog_system.entity.TbLooper;
import com.liu.my_blog_system.service.TbLooperService;
import com.liu.my_blog_system.utils.Result;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * tb_looper (TbLooper)表服务实现类
 *
 * @author liuchengjie
 * @since 2021-04-07 14:18:47
 */
@Service()
@Transactional
public class TbLooperServiceImpl extends ServiceImpl<TbLooperMapper, TbLooper> implements TbLooperService {
    /**
     * 分页查询数据
     * @param current
     * @param size
     * @return
     */
    @Override
    public Result findLooperListPage(Long current, Long size) {
        Page<TbLooper> looperPage = new Page<>(current, size);
        Page<TbLooper> page = baseMapper.selectPage(looperPage, null);
        long total = page.getTotal();
        List<TbLooper> records = page.getRecords();
        return Result.ok().data("total",total).data("records",records);
    }
}
